<template>
  <div class="about-layout">
    <div class="layout-wrapper">
      <a-row class="layout-container" :gutter="32">
        <a-col :xs="24" :sm="7" :md="6" :lg="5" :xl="5">
          <a-card class="menu-card" :bordered="false">
            <div class="menu-header">
              <UserOutlined class="user-icon" />
              <span>关于我们</span>
            </div>
            <a-menu
              mode="inline"
              :selectedKeys="[currentPath]"
              @click="handleMenuClick"
              class="side-menu"
            >
              <a-menu-item key="about">
                <span class="menu-link">关于识货</span>
                <RightOutlined class="arrow-icon" />
              </a-menu-item>
              <a-menu-item key="contact">
                <span class="menu-link">联系我们</span>
                <RightOutlined class="arrow-icon" />
              </a-menu-item>
              <a-menu-item key="feedback">
                <span class="menu-link">意见反馈</span>
                <RightOutlined class="arrow-icon" />
              </a-menu-item>
            </a-menu>
          </a-card>
        </a-col>
        <a-col :xs="24" :sm="16" :md="17" :lg="18" :xl="18">
          <a-card class="content-card" :bordered="false">
            <router-view />
          </a-card>
        </a-col>
      </a-row>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from "vue";
import { useRouter, useRoute } from "vue-router";
import { UserOutlined, RightOutlined } from "@ant-design/icons-vue";

const router = useRouter();
const route = useRoute();

// 根据当前路径计算选中的菜单项
const currentPath = computed(() => {
  const path = route.path;
  return path.split("/").pop() || "about";
});

const handleMenuClick = (e: any) => {
  router.push(`/aboutus/${e.key}`);
};
</script>

<style scoped>
.about-layout {
  min-height: 85vh;
  background: #f5f5f5;
  padding: 24px;
}

.layout-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 40px;
}

.menu-card {
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  height: auto;
  min-height: 300px;
  background: #fff;
}

.menu-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

.content-card {
  border-radius: 8px;
  min-height: 300px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  padding: 24px;
  width: 95%;
}

.menu-header {
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 500;
  color: #333;
  border-bottom: 1px solid #ffd6d9;
  background: #fff2f0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -24px -24px 0;
  border-radius: 8px 8px 0 0;
}

.user-icon {
  color: #ff4d4f;
  font-size: 18px;
}

.side-menu {
  border-right: none;
  margin: 0 -24px;
  padding: 4px 0;
}

/* 添加滚动条样式 */
.side-menu::-webkit-scrollbar {
  width: 6px;
}

.side-menu::-webkit-scrollbar-thumb {
  background-color: #ddd;
  border-radius: 3px;
}

.side-menu::-webkit-scrollbar-track {
  background-color: transparent;
}

:deep(.ant-menu-item) {
  margin: 4px 0 !important;
  padding: 0 20px !important;
  height: 44px !important;
  line-height: 44px !important;
  font-size: 14px !important;
  transition: all 0.3s ease !important;
}

:deep(.ant-menu-item:hover) {
  background-color: #fff2f0 !important;
  color: #ff4d4f !important;
  padding-left: 32px !important;
}

:deep(.ant-menu-item-selected) {
  background-color: #fff2f0 !important;
  color: #ff4d4f !important;
  padding-left: 32px !important;
  border-right: 3px solid #ff4d4f !important;
}

.menu-link {
  flex: 1;
}

.arrow-icon {
  font-size: 14px;
  opacity: 0;
  transform: translateX(-10px);
  transition: all 0.3s ease;
}

:deep(.ant-menu-item:hover) .arrow-icon {
  opacity: 1;
  transform: translateX(0);
  color: #ff4d4f;
}

:deep(.ant-menu-item-selected) .arrow-icon {
  opacity: 1;
  transform: translateX(0);
  color: #ff4d4f;
}

/* 响应式调整 */
@media screen and (max-width: 768px) {
  .layout-wrapper {
    padding: 0 16px;
  }

  .content-card {
    width: 100%;
  }
}

/* 大屏幕优化 */
@media screen and (min-width: 1920px) {
  .layout-wrapper {
    max-width: 1400px;
    padding: 0 60px;
  }
}
</style>
